package ycl.important.common.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 数据源配置
 *
 * @author: YCL
 * @date: 2021-06-04 16:32:58
 */
@Configuration
public class DruidConfig {


	/**
	 * 将自定义数据源添加到窗口中, 不让springboot自动创建
	 * ConfigurationProperties:将前缀为这个字符串的属性值注入到 druidDatasource 同名参数中
	 *
	 * @return 数据源
	 */
	@Bean
	@ConfigurationProperties(prefix = "spring.datasource")
	public DataSource druidDataSource() {
		return new DruidDataSource();
	}
}
